/**
 * @param {number[]} numbers
 * @param {number} target
 * @return {number[]}
 */
var twoSum = function (numbers, target) {
    /**
     * 由于数组有序，一个前面的数和后面的数相加，大于target，说明后面的数太大了，因为如果用再后面的数只会更大，调整后面的数往前走
     */
    let left = 0
    let right = numbers.length - 1
    while (left < right) {
        let sum = numbers[left] + numbers[right]
        if (target < sum) {
            right--
        } else if (target > sum) {
            left++
        } else {
            return [left + 1, right + 1]
        }
    }
    return []
};
let numbers = [2, 7, 11, 15], target = 9
console.log(twoSum(numbers, target));